﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// NotReviewedButNeeded
#pragma once

#include "GcmpCommonEdit.h"
#include "IGraphicsNodeReference.h"

namespace gcmp
{
    class IUiView;
    class IElement;
    class IActionInputEventArgs;
    class IControlDefinition;
    class IPickFilter;
    class IDocument;

    /// \brief 对齐操作目前所处的状态枚举值
    enum EnAlignmentStatus : int32_t
    {
        AS_NOT_START = 0,   ///< 初始化中
        AS_PICK_FIRST,      ///< 拾取目标参考
        AS_PICK_SECOND      ///< 拾取被变换的对象
    };

    /// \brief 对齐操作的Behavior，方便定制对齐Action的行为。
    class GCMP_COMMON_EDIT_EXPORT IActionAlignmentBehavior
    {
    public:
        /// \brief 析构函数
        virtual ~IActionAlignmentBehavior(){}

        /// \brief 创建ActionInputDialog内容。
        /// \param title ActionInputDialog的标题
        /// \param inputItems ActionInputDialog中的Items
        /// \return 创建成功则返回true，否则返回false
        virtual bool DefineInputDialog(std::wstring &title, std::vector<OwnerPtr<IControlDefinition>>& inputItems) = 0;

        /// \brief 获取对齐对象之间的距离。
        /// \return 返回对齐的距离。
        virtual double GetAlignmentDistance() = 0;

        /// \brief ActionInputDialog的输入响应，在输入发生变化时，会调用。
        /// \param pArgs ActionInputDialog的事件信息
        /// \return void
        virtual void OnInputEvent(IActionInputEventArgs* pArgs) = 0;

        /// \brief 在完成对齐操作时响应。把sourceNode对齐到targetNode
        /// \param pCurrentView 对齐操作所在的视图
        /// \param targetNode 对齐的目标图形引用节点
        /// \param sourceNode 要进行对齐操作的对象的图形引用节点
        /// \return void
        virtual void OnAlignmentFinished(IUiView* pCurrentView, const gcmp::IGraphicsNodeReference& targetNode, const gcmp::IGraphicsNodeReference& sourceNode) = 0;

        /// \brief 获取拾取过滤器
        /// \param ePickStatus  当前对齐操作的状态
        /// \param pDocument    当前文档
        /// \param SelectedElement  拾取到的对象
        /// \param pCurrentView 当前工作的视图
        /// \return 返回拾取过滤器
        virtual OwnerPtr<IPickFilter> GetElementPickFilter(EnAlignmentStatus ePickStatus, IDocument* pDocument, const GraphicsNodeReferenceOwnerPtrVector &SelectedElement, IUiView* pCurrentView) const = 0;
        
        /// \brief 处理拾取到的图形节点引用
        /// \param pDocument    当前文档
        /// \param nodeReferences   图形节点引用
        /// \return 无
        virtual void HandlingPickedNodeReference(IDocument* pDocument, GraphicsNodeReferenceOwnerPtrVector &nodeReferences) const = 0;
    };
}
